package com.hb.trade.server.project.section.manager;

import cn.hutool.core.collection.CollUtil;
import com.hb.core.pojo.project.section.dto.InquiryDTO;
import com.hb.core.pojo.project.section.dto.InquiryReplyDTO;
import com.hb.core.pojo.project.section.entity.InquiryReply;
import com.hb.trade.server.project.util.TradeBeanUtil;

import java.util.Collections;
import java.util.List;

/**
 * 询标
 *
 * @author yyx
 */
public class InquiryManager extends InquiryDTO {


    /**
     * 获取询标投标人数据库对象
     *
     * @return
     */
    public List<InquiryReply> getInquiryReplys() {
        final List<InquiryReplyDTO> inquiryReplyDTOS = this.getInquiryReplyDTOS(null);
        if (CollUtil.isNotEmpty(inquiryReplyDTOS)) {
            return TradeBeanUtil.copyList(inquiryReplyDTOS, InquiryReply.class);
        }
        return Collections.emptyList();
    }

    /**
     * 获取询标投标人
     *
     * @return
     */
    @Override
    public List<InquiryReplyDTO> getInquiryReplyDTOS() {
        return this.getInquiryReplyDTOS(null);
    }

    /**
     * 获取询标投标人
     *
     * @param inquiryId 询标ID
     * @return
     */
    public List<InquiryReplyDTO> getInquiryReplyDTOS(final Long inquiryId) {
        final Long id = null != inquiryId ? inquiryId : this.getId();
        final List<InquiryReplyDTO> inquiryReplyDTOS = this.getInquiryReplyDTOS();
        if (null != id && CollUtil.isNotEmpty(inquiryReplyDTOS)) {
            inquiryReplyDTOS.forEach(b -> b.setInquiryId(id));
        }
        return inquiryReplyDTOS;
    }
}
